package com.juneng.controller;

import com.juneng.common.R;
import com.juneng.utils.OSSClientUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("common/v1")
public class CommonController {

    @PostMapping("/uploadImage")
    public R upload(@RequestParam(value = "file") MultipartFile file) {
        OSSClientUtil ossClientUtil = new OSSClientUtil();
        String s = ossClientUtil.uploadImg2Oss(file);
        String url = ossClientUtil.getUrl(s);
        return R.success(url);
    }
}
